package cn.lrl.api.clients;

import cn.lrl.api.generation.pojo.User;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Service;

import java.util.List;

// 降级
@Service
public class UserClientFallbackFactory implements FallbackFactory {
    @Override
    public UserClient create(Throwable throwable) {
        return new UserClient() {
            @Override
            public User queryById(Long id) {
                return new User()
                        .setId(id)
                        .setUsername("id=>" + id + "没有对应的信息，客户端提供了降级的信息，这个服务现在已经被关闭")
                        .setPassword("没有数据~");
            }

            @Override
            public List<User> queryAll() {
                return null;
            }

            @Override
            public Boolean addDept(User dept) {
                return false;
            }
        };
    }
}
